package com.zhanglu.fun.services.chatroom.login;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhanglu.fun.services.chatroom.bean.request.TokenRequest;

import lombok.extern.slf4j.Slf4j;

/**
 * @author zhanglu
 * @description
 * @date 2017/10/21 10:26
 */
@RestController
@Slf4j
public class LoginRouter {
    @Autowired
    private TokenService tokenService;

    // @GetMapping("/auth/token")
    // public String getToken(@RequestParam("username") String username,
    // @RequestParam("password") String password) {
    // return tokenService.getToken(username, password);
    // }

    @PutMapping("/auth/login")
    public String registerToken(HttpServletResponse httpServletResponse, @RequestBody TokenRequest tokenRequest) {
        log.info("registerToken params:[username is {} | password is {}]", tokenRequest.getUsername(), tokenRequest.getPassword());
        return tokenService.registerToken(httpServletResponse, tokenRequest);
    }

    // @PostMapping("/fun/secure/token")
    // public String refreshToken(HttpServletResponse httpServletResponse,
    // @RequestBody AuthenticationUser authenticationUser) {
    // log.info("refreshToken params:[user name is {}]",
    // authenticationUser.getUsername());
    // return tokenService.refreshToken(httpServletResponse,
    // authenticationUser);
    // }

    // @DeleteMapping("/fun/secure/token")
    // public boolean deleteToken(@RequestParam("token") String token) {
    // log.info("deleteToken params:[token is {}]", token);
    // return tokenService.deleteToken(token);
    // }
}
